﻿// <copyright file="Token.cs" company="SharpSTS">
// Copyright (c) 2007, 2008 All Right Reserved, http://sharpsts.com/
//
// This source is subject to the Microsoft Permissive License.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Barry Dorrans</author>
// <email>barryd@idunno.org</email>
// <date>2008-06-14</date>
// <summary>Represents the a Token configuration element.</summary>

namespace SharpSTS.Configuration
{
    using System.Configuration;

    /// <summary>
    /// Represents a supported token type and its serialisation class.
    /// </summary>
    public sealed class Token : ConfigurationElement
    {
        /// <summary>
        /// The attribute name for the URI value.
        /// </summary>
        private const string UriConfigurationKey = @"uri";

        /// <summary>
        /// The attribute name for the class type for the token serialiser.
        /// </summary>
        private const string TypeConfigurationKey = @"type";

        /// <summary>
        /// Gets or sets the URI of the token.
        /// </summary>
        /// <value>The URI of the token.</value>
        [System.Diagnostics.CodeAnalysis.SuppressMessage(
            "Microsoft.Design", 
            "CA1056:UriPropertiesShouldNotBeStrings",
            Justification = "The URI comes from the configuration settings, and may also be in urn format.")]
        [ConfigurationProperty(UriConfigurationKey, IsKey = true, IsRequired = true)]
        public string Uri
        {
            get
            {
                return ((string)(base[UriConfigurationKey]));
            }

            set
            {
                base[UriConfigurationKey] = value;
            }
        }

        /// <summary>
        /// Gets or sets the class type which can serialise the token.
        /// </summary>
        /// <value>The class type which can serialise the token.</value>
        [ConfigurationProperty(TypeConfigurationKey, IsKey = false, IsRequired = true)]
        public string SerializerType
        {
            get
            {
                return (string)base[TypeConfigurationKey];
            }

            set
            {
                base[TypeConfigurationKey] = value;
            }
        }
    }
}
